import {request} from '../../../utils/requestUtils';
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    itemList:[],//商品列表
    typeShow:false,
    form:{
      unitName:'',// 类别名称
      unitDesc:'',// 类别描述
      stallId:'',// 摊位id
    },
    total:0,
    page: {
      pageNum: 1,
      pageSize: 100,
    },
    params: {
      keywords:''//查询关键字
    },
    current: 0,
    topHeight: 44,
    viewHeight: 640,
    dataList: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 弹窗 
    addShow(payableAmount) {
      this.setData({
        typeShow:true
      })
      this.getDiscount(payableAmount)
    },
    // 关闭弹窗
    onClose(){
      this.setData({
        typeShow:false
      })
      this.triggerEvent('discountHandler',null)
    },
    // 使用优惠卷
    exchangeCoupon(e){
      console.log('e',e)
     this.setData({
        typeShow:false
      })
      this.triggerEvent('discountHandler',e.currentTarget.dataset.info)
    },

    async getDiscount(payableAmount){
      const result = await request({
        url: `/bus/cust/customer/list?pageNum=${this.data.page.pageNum}&pageSize=${this.data.page.pageSize}`,
        method: "post",
        data: {
          params:{
            // discountCondition: payableAmount
          }
        }
      });
      if(result.data.code == 200){
        this.setData({
          itemList: result.data.rows,
          total: result.data.total
        })
        
      }
    }
  }
})